<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>新增单位</title>
<script type="text/javascript">
$(document).ready(function(){
	if($('#orgForm').val()==2){
		$('#area').attr("style","display:block");
	}
	$('#orgForm').change(function(){
		if($(this).val()=='2'){
			$('#area').attr("style","display:block");
		}else {
			$('#area').attr("style","display:none");
		}	
	});
	$("#orgName").focus();
	$("#inputForm").validate({
		rules: {
			orgName:{
				maxlength:50
			},
			shortName:{
				maxlength:50
			},
			orgNum:{
				maxlength:7
			},
			principal:{
				maxlength:50
			},
			orgAddress:{
				maxlength:50
			},
			remark:{
				maxlength:200
			},
			orgTelephone:{
				phone:true
			}
		},
		messages: {
			
		},
		submitHandler:function(form){
			//因为只有辖区局才有用管辖面积，所以先判断是否为辖区局 如果不是  则将管辖面积清空
// 			if($('#orgForm').val()!='2'){ 
// 				$('#manageArea').val("");
// 			}
			loading("保存中...");
			form.submit();
		},
		errorContainer: "#messageBox",
		errorPlacement: function(error, element) {
			$("#messageBox").text("输入有误，请先更正。");
			if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
				error.appendTo(element.parent().parent());
			} else {
				error.insertAfter(element);
			}
		}
	});
});
</script>
<style type="text/css">
#dh{
 height: 0px !important;
}
</style>
</head>
<body>
	<ul class="nav nav-tabs" style="margin:0 4px;margin-bottom:15px;">
		<li><a href="${ctx}/organization/list.do?top=${fns:encodeParam(top)}&left=${fns:encodeParam(left)}">
			<i class="icon icon-list"></i>&nbsp;<span>单位列表</span></a></li>
			<sec:authorize ifAnyGranted="ROLE_sys_organization_edit"></sec:authorize>
		<li class="active"><a href="${ctx}/organization/input.do?top=${fns:encodeParam(top)}&left=${fns:encodeParam(left)}">
		     <i class="icon icon-edit"></i>&nbsp;<span>单位添加</span></a></li>
	</ul>
	<form id="inputForm" action="${ctx}/organization/save.do?top=${fns:encodeParam(top)}&left=${fns:encodeParam(left)}"
		method="post" class="form-horizontal"  style="width:auto;">
		<input type="hidden" name="token" value="${token}">
		<tags:message content="${msg}" />
		<input type="hidden" name="id" value="${organization.id}" />
		<tags:message content="${message}" />
		<div class="control-group">
			<label class=" control-label">上级单位:</label>
			<div class="controls">
			    <tags:treeselect id="office" name="parent.id" value="${organization.parent.id}" labelName="parent.orgName" labelValue="${organization.parent.orgName}"
					title="单位" url="/organization/treeData.do" extId="${organization.id}" cssClass=" required"/>
			</div>
		</div>
		<div class="control-group">
			<label class=" control-label">单位简称:</label>
			<div class="controls">
				<input class=" required" id="orgName" name="orgName"
					type="text" value="${organization.orgName}">
			</div>
		</div>
		<div class="control-group">
			<label class=" control-label">单位名称:</label>
			<div class="controls">
				<input class=" " id="shortName" name="shortName"
					type="text" value="${organization.shortName}">
			</div>
		</div>
		<!--  -->
		<div class="control-group">
			<label class=" control-label">单位类型:</label>
			<div class="controls">
				 <pt:code name="type" category="3036" hasEmpty="false" default="${organization.orgForm}"></pt:code>
			</div>
		</div>
		<div class="control-group" >
			<label class=" control-label">单位编码:</label>
			<div class="controls">
			<input class=" " id="orgNum" name="orgNum"
					type="text" value="${organization.orgNum}">
			</div>
		</div>
		<div class="control-group" id="area" style="display: none;">
			<label class=" control-label">管辖面积:</label>
			<div class="controls">
			<input class=" " id="manageArea" name="manageArea"
					type="text" value="${organization.manageArea}">
			</div>
		</div>
<!-- 		<div class="control-group"> -->
<!-- 			<label class=" control-label">系统角色:</label> -->
<!-- 			<div class="controls"> -->
<%-- 				 <pt:code name="type" category="2004" hasEmpty="false" prompt="" default="${organization.type}"></pt:code> --%>
<!-- 			</div> -->
<!-- 		</div> -->
		
<!-- 		<div class="control-group"> -->
<!-- 			<label class=" control-label">管理区域:</label> -->
<%-- 			 <pt:code name="district" category="2002" hasEmpty="false" multiple="true" prompt="" default="${organization.district}"></pt:code> --%>
<!-- 		</div> -->
		<div class="control-group">
			<label class=" control-label">负责人:</label>
			<div class="controls">
				<input class=" " id="principal" name="principal"
					type="text" value="${organization.principal}">
			</div>
		</div>
		<div class="control-group">
			<label class=" control-label">联系电话:</label>
			<div class="controls">
				<input class=" " id="orgTelephone" name="orgTelephone"
					type="text" value="${organization.orgTelephone}">
			</div>
		</div>

		<div class="control-group">
			<label class=" control-label">地址:</label>
			<div class="controls">
				<input class=" " id="orgAddress" name="orgAddress"
					type="text" value="${organization.orgAddress}">
			</div>
		</div>
		<div class="control-group">
			<label class=" control-label">备注:</label>
			<div class="controls">
				<input class=" " id="remark" name="remark"
					type="text" value="${organization.remark}">
			</div>
		</div>
		<div class="form-actions">
		<sec:authorize ifAnyGranted="ROLE_sys_org_edit" ></sec:authorize>
				<input id="btnSubmit" class="btn btn-primary" type="submit"
					value="保 存" />&nbsp; <input id="btnCancel" class="btn"
					type="button" value="返 回" onclick="toBack()" />
		</div>
	</form>
	<script>
	$(function(){
		$(".container").height($(window).height());
	});
	</script>
</body>
</html>